package com.renjian.spring.day05.service;

import com.renjian.spring.day05.dao.BookDao;
import com.renjian.spring.day05.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
    public class BookService {
        //注入属性
        @Autowired
        private BookDao bookDao;

        //添加方法
        public void addBook(Book book){
            bookDao.add(book);
        }

        //修改方法
        public void updateBook(Book book){
            bookDao.update(book);

        }

        //删除方法
        public void deleteBook(String id){
            bookDao.delete(id);
        }

        public void queryForObject(String id){
            Book book = (Book) bookDao.queryForObj(id);
            System.out.println(book);
        }


        //查询返回某个值，总记录条数
        public void findCount(){
            int count=bookDao.find();
            System.out.println("总记录数："+count);
        }

        //查询返回集合
        public void bookList(){
            List<Book> books = bookDao.bookList();
            System.out.println(books);
        }

    }
